<html>
<!-- 
  Copyright 2010 Scott Logic Ltd.
  http://www.scottlogic.co.uk
  
  This file is part of Closure Charts.

  Closure Charts is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Closure Charts is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with Closure Charts.  If not, see <http://www.gnu.org/licenses/>.
-->
<head>
<title>JavaScript Charting Unit Tests - Label</title>
<script type="text/javascript" src="../../../../../../../../closure-library/src/main/webapp/js/goog/base.js"></script>
<script type="text/javascript" src="../unitTestDependencies.js"></script>>
<script>
	goog.require('goog.testing.jsunit');
	goog.require('goog.dom');
	
	goog.require('goog.date');
	goog.require('goog.math.Size');
	
	goog.require('scottlogic.chart.Chart');
	goog.require('scottlogic.chart.rendering.DateTimeAxis');
	goog.require('scottlogic.chart.rendering.NumericalAxis');
	goog.require('scottlogic.chart.rendering.LineSeries');
</script>
</head>
<body>
<script>  
    // Clear the canvas after the charts have been tested
    function tearDown(){
        var canvas = goog.dom.$('canvas');
        canvas.innerHTML = '';
    }
    
    function testIncrement() {
    	var min = new goog.date.UtcDateTime(2010, goog.date.month.AUG, 5, 12, 0, 0, 0);
        var max = new goog.date.UtcDateTime(2010, goog.date.month.AUG, 5, 16, 0, 0, 0);
        var x = new scottlogic.chart.rendering.DateTimeAxis();
        
        var chart = new scottlogic.chart.Chart("canvas", [300, 300]);
        chart.xAxisData.setFormatter(function(i){return i.getMinutes()});
        chart.xAxisData.setMinimum(min);
        chart.xAxisData.setMaximum(max);
    	chart.xAxisData.setStartOfHours(new goog.date.UtcDateTime(1990, 06, 22, 08));
    	chart.xAxisData.setEndOfHours(new goog.date.UtcDateTime(1990, 06, 22, 17));
    	
        var series = new scottlogic.chart.rendering.LineSeries("", [[min, -1],[max, 10]]);
        chart.addLineSeries(series);
        chart.redraw();
        
        /* test interval. note that because the position and the label text are 
        computed using the same value, we can test the text and then, 
        assuming that increment on the axis works, can assume the label is 
        in the correct location */
        assertEquals("interval y", 1, Number(chart.yAxis.labels[1].text_) - Number(chart.yAxis.labels[0].text_));
        
        assertEquals("interval x", 10, Number(chart.xAxis.labels[1].text_) - Number(chart.xAxis.labels[0].text_));
    }
</script>
<div id="canvas"></div>
</body>
</html>
